home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1999-06-17 | 44.5 KB | 1,425 lines | [ TEXT/CWIE]
// Copyright (C) 1999 Eric Roccasecca. All rights reserved. #include "X_Ray_Priv.h" #include "Layers.h" UniversalProcPtr gOldMoveWindow, gMoveWindowUPP, gOldCloseWindow, gCloseWindowUPP, gOldSizeWindow, gSizeWindowUPP, gOldHideWindow, gHideWindowUPP, gOldShowWindow, gShowWindowUPP, gOldShowHide, gShowHideUPP, gOldBringToFront, gBringToFrontUPP, gOldZoomWindow, gZoomWindowUPP, gOldSendBehind, gSendBehindUPP, gOldFindWindow, gFindWindowUPP, gOldSelectWindow, gSelectWindowUPP, gOldDragWindow, gDragWindowUPP, gOldGrowWindow, gGrowWindowUPP, gOldDragGrayRgn, gDragGrayRgnUPP, gInitWindowsUPP, gOldNewWindow, gNewWindowUPP, gOldNewCWindow, gNewCWindowUPP, gOldGetNewWindow, gGetNewWindowUPP, gOldGetNewCWindow, gGetNewCWindowUPP; Boolean gProcessManagerIsRunning; // window manager specific globals GrafPtr wm_curPort; CGrafPtr wm_origGWorld; GDHandle wm_origGDH; RgnHandle wm_transReorderVisRgn, wm_transVisRgn, wm_visRgn, wm_findWindowVisRgn, wm_strucRgn, wm_transStrucRgn, wm_origStrucRgn; X_Ray_WindowHandle wm_transWindow, wm_intersection, wm_curIntersection, wm_tempWin; X_Ray_AppRecHandle wm_curApp; short wm_workLevel = 0; WindowPtr wm_curWindow; extern short X_RayDrawLevel; // Patches pascal void X_Ray_MoveWindow (WindowPtr theWindow, short hGlobal, short vGlobal, Boolean front); pascal void X_Ray_CloseWindow (WindowPtr theWindow); pascal void X_Ray_SizeWindow (WindowPtr theWindow, short w, short h, Boolean fUpdate); pascal long X_Ray_GrowWindow (WindowPtr theWindow, Point startPt, const Rect *bBox); pascal void X_Ray_HideWindow (WindowPtr theWindow); pascal void X_Ray_ShowWindow (WindowPtr theWindow); pascal void X_Ray_BringToFront (WindowPtr theWindow); pascal void X_Ray_SelectWindow (WindowPtr theWindow); pascal void X_Ray_DragWindow (WindowPtr theWindow, Point startPt, const Rect *boundsRect); pascal void X_Ray_ShowHide (WindowPtr theWindow, Boolean showFlag); pascal void X_Ray_ZoomWindow (WindowPtr theWindow, short partCode, Boolean front); pascal void X_Ray_SendBehind (WindowPtr theWindow, WindowPtr behindWindow); pascal short X_Ray_FindWindow (Point thePoint, WindowPtr *theWindow); pascal long X_Ray_DragGrayRgn (RgnHandle theRgn, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis, DragGrayRgnProcPtr actionProc); pascal void X_Ray_InitWindows (void); pascal WindowPtr X_Ray_NewWindow (void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon); pascal WindowPtr X_Ray_NewCWindow (void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon); pascal WindowPtr X_Ray_GetNewWindow (short windowID, void *wStorage, WindowPtr behind); pascal WindowPtr X_Ray_GetNewCWindow (short windowID, void *wStorage, WindowPtr behind); void PaintBehindTransparent (void); void PaintBehindOnSwitch (LayerPtr appGlobalWindow); Boolean SetupSecretStuff (void); void ConfirmRgn (RgnHandle theRgn); Boolean InitInternalWindowManager () { wm_transVisRgn = NewRgn(); wm_visRgn = NewRgn(); wm_findWindowVisRgn = NewRgn(); wm_strucRgn = NewRgn(); wm_transStrucRgn = NewRgn(); wm_origStrucRgn = NewRgn(); wm_transReorderVisRgn = NewRgn(); // WINDOW MANAGER PATCHES // Apply patch to NewWindow /* gOldNewWindow = NGetTrapAddress (_NewWindow, ToolTrap); gNewWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_NewWindow, kNewWindowProcInfo, kPowerPCISA); if (gNewWindowUPP) NSetTrapAddress (gNewWindowUPP, _NewWindow, ToolTrap); else return false; // Apply patch to NewCWindow gOldNewCWindow = NGetTrapAddress (_NewCWindow, ToolTrap); gNewCWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_NewCWindow, kNewWindowProcInfo, kPowerPCISA); if (gNewCWindowUPP) NSetTrapAddress (gNewCWindowUPP, _NewCWindow, ToolTrap); else return false; // Apply patch to GetNewWindow gOldGetNewWindow = NGetTrapAddress (_GetNewWindow, ToolTrap); gGetNewWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_GetNewWindow, kGetNewWindowProcInfo, kPowerPCISA); if (gGetNewWindowUPP) NSetTrapAddress (gGetNewWindowUPP, _GetNewWindow, ToolTrap); else return false; // Apply patch to GetNewCWindow gOldGetNewCWindow = NGetTrapAddress (_GetNewCWindow, ToolTrap); gGetNewCWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_GetNewCWindow, kGetNewWindowProcInfo, kPowerPCISA); if (gGetNewCWindowUPP) NSetTrapAddress (gGetNewCWindowUPP, _GetNewCWindow, ToolTrap); else return false; */ // Make routine descriptor for InitWindows for local patches gInitWindowsUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_InitWindows, kInitWindowsProcInfo, GetCurrentArchitecture()); gProcessManagerIsRunning = false; // a helper flag // Apply patch to MoveWindow gOldMoveWindow = NGetTrapAddress (_MoveWindow, ToolTrap); gMoveWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_MoveWindow, kMoveWindowProcInfo, kPowerPCISA); if (gMoveWindowUPP) NSetTrapAddress (gMoveWindowUPP, _MoveWindow, ToolTrap); else return false; // Apply patch to CloseWindow gOldCloseWindow = NGetTrapAddress (_CloseWindow, ToolTrap); gCloseWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_CloseWindow, kCloseWindowProcInfo, kPowerPCISA); if (gCloseWindowUPP) NSetTrapAddress (gCloseWindowUPP, _CloseWindow, ToolTrap); else return false; // Apply patch to SizeWindow gOldSizeWindow = NGetTrapAddress (_SizeWindow, ToolTrap); gSizeWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_SizeWindow, kSizeWindowProcInfo, kPowerPCISA); if (gSizeWindowUPP) NSetTrapAddress (gSizeWindowUPP, _SizeWindow, ToolTrap); else return false; // Apply patch to GrowWindow gOldGrowWindow = NGetTrapAddress (_GrowWindow, ToolTrap); gGrowWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_GrowWindow, kGrowWindowProcInfo, kPowerPCISA); if (gGrowWindowUPP) NSetTrapAddress (gGrowWindowUPP, _GrowWindow, ToolTrap); else return false; // Apply patch to HideWindow gOldHideWindow = NGetTrapAddress (_HideWindow, ToolTrap); gHideWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_HideWindow, kHideWindowProcInfo, kPowerPCISA); if (gHideWindowUPP) NSetTrapAddress (gHideWindowUPP, _HideWindow, ToolTrap); else return false; // Apply patch to ShowWindow gOldShowWindow = NGetTrapAddress (_ShowWindow, ToolTrap); gShowWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_ShowWindow, kShowWindowProcInfo, kPowerPCISA); if (gShowWindowUPP) NSetTrapAddress (gShowWindowUPP, _ShowWindow, ToolTrap); else return false; // Apply patch to ShowHide gOldShowHide = NGetTrapAddress (_ShowHide, ToolTrap); gShowHideUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_ShowHide, kShowHideProcInfo, kPowerPCISA); if (gShowHideUPP) NSetTrapAddress (gShowHideUPP, _ShowHide, ToolTrap); else return false; // Apply patch to BringToFront gOldBringToFront = NGetTrapAddress (_BringToFront, ToolTrap); gBringToFrontUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_BringToFront, kBringToFrontProcInfo, kPowerPCISA); if (gBringToFrontUPP) NSetTrapAddress (gBringToFrontUPP, _BringToFront, ToolTrap); else return false; // Apply patch to SelectWindow gOldSelectWindow = NGetTrapAddress (_SelectWindow, ToolTrap); gSelectWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_SelectWindow, kSelectWindowProcInfo, kPowerPCISA); if (gSelectWindowUPP) NSetTrapAddress (gSelectWindowUPP, _SelectWindow, ToolTrap); else return false; // Apply patch to DragWindow gOldDragWindow = NGetTrapAddress (_DragWindow, ToolTrap); gDragWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_DragWindow, kDragWindowProcInfo, kPowerPCISA); if (gDragWindowUPP) NSetTrapAddress (gDragWindowUPP, _DragWindow, ToolTrap); else return false; // Apply patch to ZoomWindow gOldZoomWindow = NGetTrapAddress (_ZoomWindow, ToolTrap); gZoomWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_ZoomWindow, kZoomWindowProcInfo, kPowerPCISA); if (gZoomWindowUPP) NSetTrapAddress (gZoomWindowUPP, _ZoomWindow, ToolTrap); else return false; // Apply patch to SendBehind gOldSendBehind = NGetTrapAddress (_SendBehind, ToolTrap); gSendBehindUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_SendBehind, kSendBehindProcInfo, kPowerPCISA); if (gSendBehindUPP) NSetTrapAddress (gSendBehindUPP, _SendBehind, ToolTrap); else return false; // Apply patch to FindWindow gOldFindWindow = NGetTrapAddress (_FindWindow, ToolTrap); gFindWindowUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_FindWindow, kFindWindowProcInfo, kPowerPCISA); if (gFindWindowUPP) NSetTrapAddress (gFindWindowUPP, _FindWindow, ToolTrap); else return false; // Apply patch to DragGrayRgn gOldDragGrayRgn = NGetTrapAddress (_DragGrayRgn, ToolTrap); gDragGrayRgnUPP = NewRoutineDescriptor ((ProcPtr)X_Ray_DragGrayRgn, kDragGrayRgnProcInfo, kPowerPCISA); if (gDragGrayRgnUPP) NSetTrapAddress (gDragGrayRgnUPP, _DragGrayRgn, ToolTrap); else return false; if (!SetupSecretStuff()) return false; X_Ray_BuildWDEF(); return true; } pascal void X_Ray_MoveWindow (WindowPtr theWindow, short hGlobal, short vGlobal, Boolean front) { RgnHandle curVisRgn; if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); SetPort (theWindow); // to get proper graphics coordinates CopyRgn (theWindow->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); wm_transWindow = X_Ray_GetWindowRec (theWindow); wm_intersection = PortDoesIntersect (theWindow, wm_visRgn); if (wm_transWindow) { if (front) { //DebugStr ("\pX_Ray_MoveWindow"); ReorderWindow (wm_transWindow, kROMethod_MoveWindow, nil); } // preserve old visRgn before window is moved SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_transVisRgn); X_Ray_LocalToGlobalRgn (wm_transVisRgn); SetPort (wm_curPort); CopyRgn (((WindowPeek)((*wm_transWindow)->theWindow))->strucRgn, wm_transStrucRgn); } else CopyRgn (((WindowPeek)theWindow)->strucRgn, wm_origStrucRgn); if (wm_intersection) { // the moving window's visRgn does intersect at least one transWin curVisRgn = NewRgn(); wm_curIntersection = wm_intersection; while (wm_curIntersection) // walk forward through all trans wins to determine who all intersects { SetPort ((*wm_curIntersection)->theWindow); // to get proper screen coordinates CopyRgn ((*wm_curIntersection)->theWindow->visRgn, curVisRgn); X_Ray_LocalToGlobalRgn (curVisRgn); SectRgn (wm_visRgn, curVisRgn, curVisRgn); SetPort (theWindow); X_Ray_GlobalToLocalRgn (curVisRgn); InvalRgn (curVisRgn); wm_tempWin = wm_curIntersection; wm_curIntersection = GetNextWindowAbove (wm_curIntersection); } DisposeRgn (curVisRgn); SetPort (wm_curPort); } CallUniversalProc (gOldMoveWindow, kMoveWindowProcInfo, theWindow, hGlobal, vGlobal, front); AssureMovingWindowIsRefreshed (theWindow); if (wm_intersection) { // always force a redraw of window frames if they intersected a transWin before the move DiffRgn (((WindowPeek)theWindow)->strucRgn, ((WindowPeek)theWindow)->contRgn, wm_visRgn); PaintOne (theWindow, wm_visRgn); } if (wm_transWindow) PaintBehindTransparent(); else AssureOldWindowLocationIsRefreshed (theWindow, wm_origStrucRgn); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldMoveWindow, kMoveWindowProcInfo, theWindow, hGlobal, vGlobal, front); } // this may be used to guarantee that transparent windows are cleaned up if the // user calls CloseWindow() instead of CloseTransparentWindow() pascal void X_Ray_CloseWindow (WindowPtr theWindow) { if (wm_workLevel == 0) { wm_workLevel++; CallUniversalProc (gOldCloseWindow, kCloseWindowProcInfo, theWindow); wm_workLevel--; } else CallUniversalProc (gOldCloseWindow, kCloseWindowProcInfo, theWindow); } pascal void X_Ray_SizeWindow (WindowPtr theWindow, short w, short h, Boolean fUpdate) { THz curZone; GWorldFlags ugwResult; RgnHandle curVisRgn = nil; RGBColor transColor; OSErr err; if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); GetGWorld (&wm_origGWorld, &wm_origGDH); SetPort (theWindow); // to get proper graphics coordinates CopyRgn (theWindow->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); wm_transWindow = X_Ray_GetWindowRec (theWindow); wm_intersection = PortDoesIntersect (theWindow, wm_visRgn); if (wm_transWindow) { // preserve old visRgn before window is resized SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_transVisRgn); X_Ray_LocalToGlobalRgn (wm_transVisRgn); SetPort (wm_curPort); CopyRgn (((WindowPeek)((*wm_transWindow)->theWindow))->strucRgn, wm_transStrucRgn); } else CopyRgn (((WindowPeek)theWindow)->strucRgn, wm_origStrucRgn); if (wm_intersection) { //DebugStr ("\presize intersects trans wins"); // the resizing window intersects at least one transWin curVisRgn = NewRgn(); wm_curIntersection = wm_intersection; while (wm_curIntersection) // walk forward through all trans wins to determine who all intersects { SetPort ((*wm_curIntersection)->theWindow); // to get proper screen coordinates CopyRgn ((*wm_curIntersection)->theWindow->visRgn, curVisRgn); X_Ray_LocalToGlobalRgn (curVisRgn); SectRgn (wm_visRgn, curVisRgn, curVisRgn); SetPort (theWindow); X_Ray_GlobalToLocalRgn (curVisRgn); InvalRgn (curVisRgn); wm_tempWin = wm_curIntersection; wm_curIntersection = GetNextWindowAbove (wm_curIntersection); } DisposeRgn (curVisRgn); SetPort (wm_curPort); } CallUniversalProc (gOldSizeWindow, kSizeWindowProcInfo, theWindow, w, h, fUpdate); if (wm_transWindow) { HLock ((Handle)wm_transWindow); curZone = GetZone(); // make sure any memory is allocated in system heap SetZone (SystemZone()); ugwResult = UpdateGWorld (&(*wm_transWindow)->underBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\punderBuffer"); } else { SetGWorld ((*wm_transWindow)->underBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->underBuffer)); EraseRect (&(*wm_transWindow)->underBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->underBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->contentBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pcontentBuffer"); } else { SetGWorld ((*wm_transWindow)->contentBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->contentBuffer)); EraseRect (&(*wm_transWindow)->contentBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->contentBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->mixBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pmixBuffer"); } else { SetGWorld ((*wm_transWindow)->mixBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->mixBuffer)); EraseRect (&(*wm_transWindow)->mixBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->mixBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->maskBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pmaskBuffer"); } else { SetGWorld ((*wm_transWindow)->maskBuffer, nil); transColor.red = transColor.green = transColor.blue = (*wm_transWindow)->transparency; RGBForeColor (&transColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->maskBuffer)); PaintRect (&(*wm_transWindow)->maskBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->maskBuffer)); BackColor (whiteColor); ForeColor (blackColor); } HUnlock ((Handle)wm_transWindow); SetGWorld (wm_origGWorld, wm_origGDH); // restore gworld environment SetPort ((*wm_transWindow)->theWindow); InvalRect (&(*wm_transWindow)->theWindow->portRect); SetPort (wm_curPort); SetZone (curZone); PaintBehindTransparent(); } else AssureOldWindowLocationIsRefreshed (theWindow, wm_origStrucRgn); if (wm_intersection) { // always force a redraw of window frames if they intersected a transWin before the resize DiffRgn (((WindowPeek)theWindow)->strucRgn, ((WindowPeek)theWindow)->contRgn, wm_visRgn); PaintOne (theWindow, wm_visRgn); } SetGWorld (wm_origGWorld, wm_origGDH); // restore gworld environment SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldSizeWindow, kSizeWindowProcInfo, theWindow, w, h, fUpdate); } pascal long X_Ray_GrowWindow (WindowPtr theWindow, Point startPt, const Rect *bBox) { THz curZone; GWorldFlags ugwResult; RgnHandle curVisRgn = nil; long result = 0; OSErr err; RGBColor transColor; if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); SetPort (theWindow); // to get proper graphics coordinates CopyRgn (theWindow->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); wm_transWindow = X_Ray_GetWindowRec (theWindow); wm_intersection = PortDoesIntersect (theWindow, wm_visRgn); if (wm_transWindow) { // preserve old visRgn before window is grown SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_transVisRgn); X_Ray_LocalToGlobalRgn (wm_transVisRgn); SetPort (wm_curPort); CopyRgn (((WindowPeek)((*wm_transWindow)->theWindow))->strucRgn, wm_transStrucRgn); } if (wm_intersection) { // the growing window intersects at least one transWin curVisRgn = NewRgn(); wm_curIntersection = wm_intersection; while (wm_curIntersection) // walk forward through all trans wins to determine who all intersects { SetPort ((*wm_curIntersection)->theWindow); // to get proper screen coordinates CopyRgn ((*wm_curIntersection)->theWindow->visRgn, curVisRgn); X_Ray_LocalToGlobalRgn (curVisRgn); SectRgn (wm_visRgn, curVisRgn, curVisRgn); SetPort (theWindow); X_Ray_GlobalToLocalRgn (curVisRgn); InvalRgn (curVisRgn); wm_tempWin = wm_curIntersection; wm_curIntersection = GetNextWindowAbove (wm_curIntersection); } DisposeRgn (curVisRgn); SetPort (wm_curPort); } result = CallUniversalProc (gOldGrowWindow, kGrowWindowProcInfo, theWindow, startPt, bBox); if (wm_intersection) { // always force a redraw of window frames if they intersected a transWin before the growing DiffRgn (((WindowPeek)theWindow)->strucRgn, ((WindowPeek)theWindow)->contRgn, wm_visRgn); PaintOne (theWindow, wm_visRgn); } if (wm_transWindow && result) { HLock ((Handle)wm_transWindow); curZone = GetZone(); // make sure any memory is allocated in system heap SetZone (SystemZone()); ugwResult = UpdateGWorld (&(*wm_transWindow)->underBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\punderBuffer"); } else { SetGWorld ((*wm_transWindow)->underBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->underBuffer)); EraseRect (&(*wm_transWindow)->underBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->underBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->contentBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pcontentBuffer"); } else { SetGWorld ((*wm_transWindow)->contentBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->contentBuffer)); EraseRect (&(*wm_transWindow)->contentBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->contentBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->mixBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pmixBuffer"); } else { SetGWorld ((*wm_transWindow)->mixBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->mixBuffer)); EraseRect (&(*wm_transWindow)->mixBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->mixBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->maskBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pmaskBuffer"); } else { SetGWorld ((*wm_transWindow)->maskBuffer, nil); transColor.red = transColor.green = transColor.blue = (*wm_transWindow)->transparency; RGBForeColor (&transColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->maskBuffer)); PaintRect (&(*wm_transWindow)->maskBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->maskBuffer)); BackColor (whiteColor); ForeColor (blackColor); } HUnlock ((Handle)wm_transWindow); SetGWorld (wm_origGWorld, wm_origGDH); // restore gworld environment SetPort ((*wm_transWindow)->theWindow); InvalRect (&(*wm_transWindow)->theWindow->portRect); SetPort (wm_curPort); // restore graphics environment SetZone (curZone); PaintBehindTransparent(); } SetPort (wm_curPort); wm_workLevel--; } else result = CallUniversalProc (gOldGrowWindow, kGrowWindowProcInfo, theWindow, startPt, bBox); return result; } pascal void X_Ray_HideWindow (WindowPtr theWindow) { if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); wm_transWindow = X_Ray_GetWindowRec (theWindow); if (wm_transWindow) ReorderWindow (wm_transWindow, kROMethod_HideWindow, (WindowPtr)((WindowPeek)theWindow)->nextWindow); CallUniversalProc (gOldHideWindow, kHideWindowProcInfo, theWindow); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldHideWindow, kHideWindowProcInfo, theWindow); } pascal void X_Ray_ShowWindow (WindowPtr theWindow) { if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); wm_transWindow = X_Ray_GetWindowRec (theWindow); CallUniversalProc (gOldShowWindow, kShowWindowProcInfo, theWindow); if (wm_transWindow) PaintBehindTransparent(); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldShowWindow, kShowWindowProcInfo, theWindow); } pascal void X_Ray_ShowHide (WindowPtr theWindow, Boolean showFlag) { if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); wm_transWindow = X_Ray_GetWindowRec (theWindow); // this conditional statement must occur BEFORE CallUniversalProc if (!showFlag) // window is being hidden, if it is frontMost, hidding it will reorder it if (wm_transWindow && (LMGetWindowList() == theWindow)) ReorderWindow (wm_transWindow, kROMethod_ShowHide, (WindowPtr)((WindowPeek)theWindow)->nextWindow); CallUniversalProc (gOldShowHide, kShowHideProcInfo, theWindow, showFlag); if (showFlag && wm_transWindow) PaintBehindTransparent(); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldShowHide, kShowHideProcInfo, theWindow, showFlag); } pascal void X_Ray_BringToFront (WindowPtr theWindow) { X_Ray_AppRecHandle switchedApp; RgnHandle intersectRgn = nil, updateRgn = nil; WindowPtr curWindow = nil, repaintWindow = nil; if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); switchedApp = WindowIsGlobalAppWindow (theWindow); if (switchedApp) { updateRgn = ReorderApp (switchedApp, kROMethod_BringToFront); CleanAppList(); } else { wm_transWindow = X_Ray_GetWindowRec (theWindow); if (wm_transWindow) { CopyRgn (theWindow->visRgn, wm_transReorderVisRgn); // needed for AssureUpdateForTransparent() ReorderWindow (wm_transWindow, kROMethod_BringToFront, nil); } } CallUniversalProc (gOldBringToFront, kBringToFrontProcInfo, theWindow); // force a redraw of new forground app's windows that may intersect // transparent windows of the app that was foreground if (switchedApp && updateRgn && !EmptyRgn (updateRgn)) { intersectRgn = NewRgn(); curWindow = GetFirstLayerWindow ((LayerPtr)(*switchedApp)->appGlobalWindow); while (curWindow) { SectRgn (updateRgn, ((WindowPeek)curWindow)->strucRgn, intersectRgn); if (!EmptyRgn (intersectRgn)) repaintWindow = curWindow; // remember the back most window for PaintOne() curWindow = (WindowPtr)((WindowPeek)curWindow)->nextWindow; } if (repaintWindow) PaintOne (repaintWindow, updateRgn); DisposeRgn (intersectRgn); DisposeRgn (updateRgn); } if (switchedApp) { wm_transWindow = (*switchedApp)->windowList; while (wm_transWindow) { PaintBehindTransparent(); wm_transWindow = (*wm_transWindow)->nextWindow; } } else { if (wm_transWindow) AssureUpdateForTransparent (theWindow); else AssureMovingWindowIsRefreshed (theWindow); } SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldBringToFront, kBringToFrontProcInfo, theWindow); } pascal void X_Ray_SelectWindow (WindowPtr theWindow) { if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); wm_transWindow = X_Ray_GetWindowRec (theWindow); if (wm_transWindow) { //DebugStr ("\pX_Ray_SelectWindow"); CopyRgn (theWindow->visRgn, wm_transReorderVisRgn); // needed for assuring a proper update after reorder ReorderWindow (wm_transWindow, kROMethod_SelectWindow, nil); } CallUniversalProc (gOldSelectWindow, kSelectWindowProcInfo, theWindow); AssureMovingWindowIsRefreshed (theWindow); if (wm_transWindow) { AssureUpdateForTransparent (theWindow); PaintBehindTransparent(); } SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldSelectWindow, kSelectWindowProcInfo, theWindow); } pascal void X_Ray_DragWindow (WindowPtr theWindow, Point startPt, const Rect *boundsRect) { RgnHandle curVisRgn; if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); SetPort (theWindow); // to get proper graphics coordinates CopyRgn (theWindow->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); wm_transWindow = X_Ray_GetWindowRec (theWindow); wm_intersection = PortDoesIntersect (theWindow, wm_visRgn); if (wm_transWindow) { if (!isPressed(0x37)) // if command key is not down { //DebugStr ("\pX_Ray_DragWindow"); ReorderWindow (wm_transWindow, kROMethod_DragWindow, nil); } // preserve old visRgn before window is moved SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_transVisRgn); X_Ray_LocalToGlobalRgn (wm_transVisRgn); SetPort (wm_curPort); CopyRgn (((WindowPeek)((*wm_transWindow)->theWindow))->strucRgn, wm_transStrucRgn); } else CopyRgn (((WindowPeek)theWindow)->strucRgn, wm_origStrucRgn); if (wm_intersection) { // the moving window's visRgn does intersect at least one transWin curVisRgn = NewRgn(); wm_curIntersection = wm_intersection; while (wm_curIntersection) // walk forward through all trans wins to determine who all intersects { SetPort ((*wm_curIntersection)->theWindow); // to get proper screen coordinates CopyRgn ((*wm_curIntersection)->theWindow->visRgn, curVisRgn); X_Ray_LocalToGlobalRgn (curVisRgn); SectRgn (wm_visRgn, curVisRgn, curVisRgn); SetPort (theWindow); X_Ray_GlobalToLocalRgn (curVisRgn); InvalRgn (curVisRgn); wm_tempWin = wm_curIntersection; wm_curIntersection = GetNextWindowAbove (wm_curIntersection); } DisposeRgn (curVisRgn); SetPort (wm_curPort); } CallUniversalProc (gOldDragWindow, kDragWindowProcInfo, theWindow, startPt, boundsRect); // check to see if window intersects any transparent windows behind it after the move // this fixes a problem with window frames and contents not redrawing correctly after a move if (!isPressed(0x37)) // if command key is not down AssureMovingWindowIsRefreshed (theWindow); if (wm_intersection) { // always force a redraw of window frames if they intersected a transWin before the move DiffRgn (((WindowPeek)theWindow)->strucRgn, ((WindowPeek)theWindow)->contRgn, wm_visRgn); PaintOne (theWindow, wm_visRgn); } if (wm_transWindow) PaintBehindTransparent(); else AssureOldWindowLocationIsRefreshed (theWindow, wm_origStrucRgn); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldDragWindow, kDragWindowProcInfo, theWindow, startPt, boundsRect); } pascal void X_Ray_ZoomWindow (WindowPtr theWindow, short partCode, Boolean front) { RgnHandle curVisRgn; THz curZone; GWorldFlags ugwResult; OSErr err; RGBColor transColor; if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); GetGWorld (&wm_origGWorld, &wm_origGDH); SetPort (theWindow); // to get proper graphics coordinates CopyRgn (theWindow->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); wm_transWindow = X_Ray_GetWindowRec (theWindow); wm_intersection = PortDoesIntersect (theWindow, wm_visRgn); if (wm_transWindow) { // preserve old visRgn before window is resized SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_transVisRgn); X_Ray_LocalToGlobalRgn (wm_transVisRgn); SetPort (wm_curPort); CopyRgn (((WindowPeek)((*wm_transWindow)->theWindow))->strucRgn, wm_transStrucRgn); } if (wm_intersection) { //DebugStr ("\presize intersects trans wins"); // the resizing window intersects at least one transWin curVisRgn = NewRgn(); wm_curIntersection = wm_intersection; while (wm_curIntersection) // walk forward through all trans wins to determine who all intersects { SetPort ((*wm_curIntersection)->theWindow); // to get proper screen coordinates CopyRgn ((*wm_curIntersection)->theWindow->visRgn, curVisRgn); X_Ray_LocalToGlobalRgn (curVisRgn); SectRgn (wm_visRgn, curVisRgn, curVisRgn); SetPort (theWindow); X_Ray_GlobalToLocalRgn (curVisRgn); InvalRgn (curVisRgn); wm_tempWin = wm_curIntersection; wm_curIntersection = GetNextWindowAbove (wm_curIntersection); } DisposeRgn (curVisRgn); SetPort (wm_curPort); } CallUniversalProc (gOldZoomWindow, kZoomWindowProcInfo, theWindow, partCode, front); if (wm_transWindow) { HLock ((Handle)wm_transWindow); curZone = GetZone(); // make sure any memory is allocated in system heap SetZone (SystemZone()); ugwResult = UpdateGWorld (&(*wm_transWindow)->underBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\punderBuffer"); } else { SetGWorld ((*wm_transWindow)->underBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->underBuffer)); EraseRect (&(*wm_transWindow)->underBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->underBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->contentBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pcontentBuffer"); } else { SetGWorld ((*wm_transWindow)->contentBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->contentBuffer)); EraseRect (&(*wm_transWindow)->contentBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->contentBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->mixBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pmixBuffer"); } else { SetGWorld ((*wm_transWindow)->mixBuffer, nil); ForeColor (blackColor); BackColor (whiteColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->mixBuffer)); EraseRect (&(*wm_transWindow)->mixBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->mixBuffer)); } ugwResult = UpdateGWorld (&(*wm_transWindow)->maskBuffer, 32, &(*wm_transWindow)->theWindow->portRect, nil, nil, 0); err = QDError(); if (err != noErr) { DebugNum (err); DebugStr ("\pmaskBuffer"); } else { SetGWorld ((*wm_transWindow)->maskBuffer, nil); transColor.red = transColor.green = transColor.blue = (*wm_transWindow)->transparency; RGBForeColor (&transColor); LockPixels (GetGWorldPixMap((*wm_transWindow)->maskBuffer)); PaintRect (&(*wm_transWindow)->maskBuffer->portRect); UnlockPixels (GetGWorldPixMap((*wm_transWindow)->maskBuffer)); BackColor (whiteColor); ForeColor (blackColor); } HUnlock ((Handle)wm_transWindow); SetGWorld (wm_origGWorld, wm_origGDH); // restore gworld environment SetPort ((*wm_transWindow)->theWindow); InvalRect (&(*wm_transWindow)->theWindow->portRect); SetPort (wm_curPort); // restore graphics environment SetZone (curZone); PaintBehindTransparent(); } if (wm_intersection) { // always force a redraw of window frames if they intersected a transWin before the resize DiffRgn (((WindowPeek)theWindow)->strucRgn, ((WindowPeek)theWindow)->contRgn, wm_visRgn); PaintOne (theWindow, wm_visRgn); } SetGWorld (wm_origGWorld, wm_origGDH); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldZoomWindow, kZoomWindowProcInfo, theWindow, partCode, front); } pascal void X_Ray_SendBehind (WindowPtr theWindow, WindowPtr behindWindow) { if (wm_workLevel == 0) { wm_workLevel++; GetPort (&wm_curPort); wm_transWindow = X_Ray_GetWindowRec (theWindow); if (wm_transWindow) { //DebugStr ("\pX_Ray_SendBehind"); ReorderWindow (wm_transWindow, kROMethod_SendBehind, behindWindow); } CallUniversalProc (gOldSendBehind, kSendBehindProcInfo, theWindow, behindWindow); SetPort (wm_curPort); wm_workLevel--; } else CallUniversalProc (gOldSendBehind, kSendBehindProcInfo, theWindow, behindWindow); } pascal short X_Ray_FindWindow (Point thePoint, WindowPtr *theWindow) { short winPart; long result; X_Ray_WindowHandle curTransWindow; WindowPtr curWindow; GrafPtr curPort; // this definately works when the foreground app has transWins but doesn't bring background apps forward if they have transWins // this is a hack to build proper bounds for FindWindow to find transparent windows // basically all regions FindWindow checks are modified to mimic what FindWindow expects to find GetPort (&curPort); curTransWindow = GetNextWindowBehind (nil); while (curTransWindow) { if ((*curTransWindow)->transparency == kTransparencyOpaque) { SetPort ((*curTransWindow)->theWindow); CopyRgn (((*curTransWindow)->theWindow)->visRgn, wm_findWindowVisRgn); X_Ray_LocalToGlobalRgn (wm_findWindowVisRgn); if (!((*curTransWindow)->windowKind&kTSMWindow)) UnionRgn (((WindowPeek)(*(*curTransWindow)->owner)->appGlobalWindow)->strucRgn, wm_findWindowVisRgn, ((WindowPeek)(*(*curTransWindow)->owner)->appGlobalWindow)->strucRgn); UnionRgn (((WindowPeek)(*curTransWindow)->theWindow)->strucRgn, ((WindowPeek)(*curTransWindow)->theWindow)->contRgn, ((WindowPeek)(*curTransWindow)->theWindow)->strucRgn); } curTransWindow = GetNextWindowBehind (curTransWindow); } SetPort (curPort); result = CallUniversalProc (gOldFindWindow, kFindWindowProcInfo, thePoint, theWindow); winPart = LoWord (result); curTransWindow = GetNextWindowBehind (nil); while (curTransWindow) { if ((*curTransWindow)->transparency == kTransparencyOpaque) { SetPort ((*curTransWindow)->theWindow); CopyRgn (((*curTransWindow)->theWindow)->visRgn, wm_findWindowVisRgn); X_Ray_LocalToGlobalRgn (wm_findWindowVisRgn); if (!((*curTransWindow)->windowKind&kTSMWindow)) { DiffRgn (((WindowPeek)(*(*curTransWindow)->owner)->appGlobalWindow)->strucRgn, wm_findWindowVisRgn, ((WindowPeek)(*(*curTransWindow)->owner)->appGlobalWindow)->strucRgn); // by subtracting from the strucRgn of the appGlobalWindow, windows beneath curTransWindow may not be included now so re-add their strucRgns curWindow = (GrafPtr)((WindowPeek)(*curTransWindow)->theWindow)->nextWindow; while (curWindow) { UnionRgn (((WindowPeek)(*(*curTransWindow)->owner)->appGlobalWindow)->strucRgn, ((WindowPeek)curWindow)->strucRgn, ((WindowPeek)(*(*curTransWindow)->owner)->appGlobalWindow)->strucRgn); curWindow = (GrafPtr)((WindowPeek)curWindow)->nextWindow; } } DiffRgn (((WindowPeek)(*curTransWindow)->theWindow)->strucRgn, ((WindowPeek)(*curTransWindow)->theWindow)->contRgn, ((WindowPeek)(*curTransWindow)->theWindow)->strucRgn); } curTransWindow = GetNextWindowBehind (curTransWindow); } SetPort (curPort); return winPart; } // this needs some real handling pascal long X_Ray_DragGrayRgn (RgnHandle theRgn, Point startPt, const Rect *limitRect, const Rect *slopRect, short axis, DragGrayRgnProcPtr actionProc) { X_RayDrawLevel++; // turn off X_Ray CallUniversalProc (gOldDragGrayRgn, kDragGrayRgnProcInfo, theRgn, startPt, limitRect, slopRect, axis, actionProc); X_RayDrawLevel--; // turn on X_Ray } // not actually used pascal WindowPtr X_Ray_NewWindow (void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) { long result; result = CallUniversalProc (gOldNewWindow, kNewWindowProcInfo, wStorage, boundsRect, title, visible, theProc, behind, goAwayFlag, refCon); return (WindowPtr)result; } // not actually used pascal WindowPtr X_Ray_NewCWindow (void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) { long result; result = CallUniversalProc (gOldNewCWindow, kNewWindowProcInfo, wStorage, boundsRect, title, visible, theProc, behind, goAwayFlag, refCon); return (WindowPtr)result; } // not actually used pascal WindowPtr X_Ray_GetNewWindow (short windowID, void *wStorage, WindowPtr behind) { long result; result = CallUniversalProc (gOldGetNewWindow, kGetNewWindowProcInfo, windowID, wStorage, behind); return (WindowPtr)result; } // not actually used pascal WindowPtr X_Ray_GetNewCWindow (short windowID, void *wStorage, WindowPtr behind) { long result; result = CallUniversalProc (gOldGetNewCWindow, kGetNewWindowProcInfo, windowID, wStorage, behind); return (WindowPtr)result; } // When an app calls InitWindows() the Layer Manager makes the app's layer. // By watching an app's InitWindows() call I can get its layer. pascal void X_Ray_InitWindows (void) { UniversalProcPtr localOldInitWindows; Boolean newApp; // figure out which app I am in and call its original InitWindows(). Ug! localOldInitWindows = GetLocalTrap (_InitWindows); CallUniversalProc (localOldInitWindows, kInitWindowsProcInfo); newApp = AppInitWindowsState(); if (newApp) SetAppGlobalWindow ((WindowPtr)GetCurLayer()); } // WINDOW MANAGER UTILITY FUNCTIONS // forces redraw of all windows behind wm_transWin // and sets update events in all intersecting windows so they will be updated behind this window void PaintBehindTransparent (void) { Boolean firstTime = true; WindowPtr serviceWindow, backMostStrucIntersection; // wm_transVisRgn may not always be empty, if (*wm_transWindow)->theWindow has moved // it will contain the old visRgn of (*wm_transWindow)->theWindow before it was moved SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); UnionRgn (wm_visRgn, wm_transVisRgn, wm_transVisRgn); PaintBehind ((*wm_transWindow)->theWindow, wm_transVisRgn); CalcVisBehind ((*wm_transWindow)->theWindow, wm_transVisRgn); // wm_transStrucRgn may not always be empty, if (*wm_transWindow)->theWindow has moved/grown // it will contain the old strucRgn of (*wm_transWindow)->theWindow before it was moved // this means we now need to accumulate the new strucRgn of the moved/resized window if (!EmptyRgn (wm_transStrucRgn)) UnionRgn (((WindowPeek)((*wm_transWindow)->theWindow))->strucRgn, wm_transStrucRgn, wm_transStrucRgn); SetPort (wm_curPort); // restore drawing environ // walk all windows in all apps behind (*wm_transWindow)->theWindow // if they are visible, comapre their visRgns (copied and made global) to the wm_transVisRgn // if they intersect add to their updateRgns // if their strucRgns intersect, redraw their window frames if ((*wm_transWindow)->windowKind&kTSMWindow) wm_curApp = gCommRec.appList; else wm_curApp = (*(*wm_transWindow)->owner)->nextApp; wm_curWindow = (GrafPtr)((WindowPeek)(*wm_transWindow)->theWindow)->nextWindow; // start behind the current window // BUGBUG this will not properly see all windows in the TSM layer while (wm_curApp || firstTime) { backMostStrucIntersection = nil; if (!firstTime) { if (!(((*wm_curApp)->mode)&modeOnlyBackground)) wm_curWindow = GetFirstLayerWindow ((*wm_curApp)->appGlobalWindow); else wm_curWindow = nil; } while (wm_curWindow) { if (((WindowPeek)wm_curWindow)->visible) // only matters if window is visible { SetPort (wm_curWindow); //DebugStr ("\p2 pre CopyRgn"); //DebugNum ((long)wm_curWindow); //DebugNum ((long)wm_curWindow->visRgn); CopyRgn (wm_curWindow->visRgn, wm_visRgn); //DebugStr ("\p2 post CopyRgn"); //DebugStr ("\p--------"); X_Ray_LocalToGlobalRgn (wm_visRgn); SectRgn (wm_visRgn, wm_transVisRgn, wm_visRgn); X_Ray_GlobalToLocalRgn (wm_visRgn); InvalRgn (wm_visRgn); // force window updates that globally intersect the transparent window's new and old visRgn // find out the back most struRgn intersection SectRgn (((WindowPeek)wm_curWindow)->strucRgn, wm_transStrucRgn, wm_strucRgn); if (!EmptyRgn(wm_strucRgn)) backMostStrucIntersection = wm_curWindow; } wm_curWindow = (GrafPtr)((WindowPeek)wm_curWindow)->nextWindow; } // redraw back most intersecting window frame in each layer // this redraw will propogate forward in the layer's window list if (backMostStrucIntersection) PaintOne (backMostStrucIntersection, wm_transStrucRgn); if (!firstTime) { if (wm_curApp) wm_curApp = (*wm_curApp)->nextApp; } else firstTime = false; } SetEmptyRgn (wm_transStrucRgn); SetEmptyRgn (wm_strucRgn); SetEmptyRgn (wm_transVisRgn); SetEmptyRgn (wm_visRgn); SetPort (wm_curPort); // restore drawing environ } // redraws intersecting windows of the app being switched to the foreground where they intersect a transWin void PaintBehindOnSwitch (LayerPtr appGlobalWindow) { // upon entry, wm_visRgn contains the sum of all the visRgns of all transWins of the app being switched out X_RayDrawLevel++; // suspend X_Ray SetPort ((*wm_transWindow)->theWindow); CopyRgn (((*wm_transWindow)->theWindow)->visRgn, wm_transVisRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); SetPort (wm_curPort); // restore drawing environ // redraw all of the new apps windows wm_curWindow = GetFirstLayerWindow (appGlobalWindow); //wm_curWindow = (WindowPtr)((WindowPeek)(appGlobalWindow))->windowPic; while (wm_curWindow) { if (((WindowPeek)wm_curWindow)->visible) // only matters if window is visible { PaintOne (wm_curWindow, ((WindowPeek)appGlobalWindow)->strucRgn); SetPort (wm_curWindow); CopyRgn (wm_curWindow->visRgn, wm_visRgn); X_Ray_LocalToGlobalRgn (wm_visRgn); SectRgn (wm_visRgn, wm_transVisRgn, wm_visRgn); X_Ray_GlobalToLocalRgn (wm_visRgn); InvalRgn (wm_visRgn); // force window updates that globally intersect wm_visRgn } wm_curWindow = (WindowPtr)((WindowPeek)wm_curWindow)->nextWindow; } SetEmptyRgn (wm_transVisRgn); SetEmptyRgn (wm_visRgn); SetPort (wm_curPort); // restore drawing environ X_RayDrawLevel--; // resume X_Ray } void AssureUpdateForTransparent (WindowPtr theWindow) { // when trans windows come forward their update areas are not // computed correctly so help them out DiffRgn (theWindow->visRgn, wm_transReorderVisRgn, wm_transReorderVisRgn); SetPort (theWindow); InvalRgn (wm_transReorderVisRgn); SetEmptyRgn (wm_transReorderVisRgn); }